﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using indicadores.Models;
using System.Web.Security;

namespace indicadores.Controllers
{
    public class LoginController : Controller
    {
        LoginRepositorio lr = new LoginRepositorio();

        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Index2()
        {
            FormsAuthentication.SetAuthCookie("Cristianbl", true);
            try
            {
                return Redirect(Request.QueryString["ReturnUrl"].ToString());
            }
            catch
            {
            }
            return RedirectToAction("Index");
        }

        public ActionResult Novo()
        {
            return View();
        }

        [HttpPost]
        public string Novo(Login l)
        {
            return "";
        }

        public ActionResult Listar()
        {
            return View(lr.BuscaTodas());
        }

        public string Apagar(int id)
        {
            try
            {
                lr.Apagar(id);
                return "Usuário Removido com sucesso.";
            }
            catch
            {
                return "Ocorreu algum erro com o banco de dados!";
            }
        }

    }
}